#include "fibevent.h"

#include "IocpOperation.h"
#include "BaseFiberClientHandler.h"
#include "IocpIoBaseInitiator.h"

BaseFiberClientHandler::BaseFiberClientHandler()
	:m_io(NULL)
	,m_server(NULL)
{

}

BaseFiberClientHandler::~BaseFiberClientHandler()
{

}

void BaseFiberClientHandler::DoWork( IocpIoBaseInitiator*  )
{

}

void BaseFiberClientHandler::SetIo( IocpIoBaseInitiator* io )
{
	m_io = io;
}

void BaseFiberClientHandler::Run()
{
	if(!m_io)
	{
		LFATAL("No socket in FiberClietnHandler");
		abort();
	}

	if(!m_server)
	{
		LFATAL("m_server pointer in FiberClietnHandler is null");
		abort();
	}

	DoWork(m_io);
	
	delete m_io;
	m_io = NULL;
}

void BaseFiberClientHandler::SetServer( BaseFiberServer* server )
{
	m_server = server;
}

BaseFiberServer* BaseFiberClientHandler::GetServer()
{
	return m_server;
}
